package cn.fayang.ymcc.exception;

import cn.fayang.ymcc.constant.GlobalExceptionConstant;
import cn.fayang.ymcc.constant.YmccExceptionConstant;
import cn.fayang.ymcc.result.JSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = GlobalException.class)
    public JSONResult globalExceptionHandler(GlobalException e) {
        // 把错误信息输入到日志中
        e.printStackTrace();
        return JSONResult.error(e.getMessage(),e.getCode());
    }

    @ExceptionHandler(Exception.class)
    public JSONResult exceptionHandler(Exception e){
        e.printStackTrace();
        return JSONResult.error(e.getMessage());
    }



}
